<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>基层AI辅助诊断系统 - 药品管理</title>
    <!-- 引入Element Plus的样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-plus/dist/index.css">
    <!-- 引入Vue 3 -->
    <script src="https://unpkg.com/vue@3"></script>
    <!-- 引入Element Plus组件库 -->
    <script src="https://unpkg.com/element-plus"></script>
    <!-- 引入中文语言包 -->
    <script src="https://unpkg.com/element-plus/dist/locale/zh-cn.min.js"></script>
    <style>
        /* 基础样式 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        html, body {
            height: 100%;
            margin: 0;
            padding: 0;
            overflow: hidden; /* 防止页面滚动 */
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
            background: #FFFFFF;
            color: var(--text-primary);
            font-size: 14px;
            line-height: 1.5;
        }

        /* 色彩系统 - 基于HIS系统现代极简风设计规范 */
        :root {
            /* 主色调 */
            --primary: #0F6CBD;
            --primary-light: #D0E7FF;
            --primary-dark: #0A4F8D;

            /* 辅助色 */
            --success: #0F8A5F;
            --warning: #F59337;
            --error: #D13438;
            --info: #0078D4;

            /* 中性色 - 文字 */
            --text-primary: #1A1A1A;
            --text-secondary: #4D4D4D;
            --text-tertiary: #767676;
            --text-disabled: #A6A6A6;

            /* 中性色 - 边框与分割线 */
            --border-strong: #CCCCCC;
            --border-normal: #E0E0E0;
            --border-light: #F0F0F0;
            --divider: #F5F5F5;

            /* 中性色 - 背景 */
            --bg-primary: #FFFFFF;
            --bg-secondary: #F9F9F9;
            --bg-card: #FFFFFF;
            --bg-disabled: #F5F5F5;

            /* 医疗专业色 */
            --medical-critical: #B91C1C;
            --medical-abnormal: #F59E0B;
            --medical-normal: #10B981;
            --medical-pending: #3B82F6;
            --medical-completed: #9CA3AF;

            /* 间距系统 */
            --spacing-2: 2px;
            --spacing-4: 4px;
            --spacing-8: 8px;
            --spacing-12: 12px;
            --spacing-16: 16px;
            --spacing-24: 24px;
            --spacing-32: 32px;
            --spacing-40: 40px;
            --spacing-48: 48px;

            /* 字体大小 */
            --font-page-title: 20px;
            --font-card-title: 16px;
            --font-table-title: 14px;
            --font-body: 14px;
            --font-table: 13px;
            --font-small: 12px;

            /* 行高 */
            --line-height-title: 1.4;
            --line-height-body: 1.5;
            --line-height-table: 1.2;
            --line-height-form: 1.4;

            /* 圆角 */
            --radius-small: 2px;
            --radius-medium: 4px;

            /* 动画时间 */
            --transition-fast: 150ms;
            --transition-normal: 200ms;
            --transition-slow: 300ms;

            /* 导航统一宽度 */
            --nav-item-width: 140px;
        }

        [v-cloak] {
            display: none;
        }

        /* 布局容器 */
        .container {
            width: 100%;
            height: 100vh; /* 使用固定高度而不是最小高度 */
            display: flex;
            flex-direction: column;
            background-color: var(--bg-secondary);
            overflow: hidden; /* 防止整体页面滚动 */
        }

        /* 顶部导航栏 */
        .header {
            height: 60px;
            background-color: var(--bg-primary);
            border-bottom: 1px solid var(--border-normal);
            display: flex;
            align-items: center;
            padding: 0 var(--spacing-24);
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
            position: relative;
            z-index: 100;
        }

        .header-spacer {
            width: 200px;
            flex-shrink: 0;
        }

        #app-nav {
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            z-index: 10;
            width: calc(100% - 400px);
            display: flex;
            justify-content: center;
        }

        /* Element Plus菜单样式覆盖 */
        .el-menu {
            border: none !important;
            background-color: transparent !important;
        }

        .el-menu--horizontal > .el-menu-item,
        .el-menu--horizontal > .el-sub-menu .el-sub-menu__title {
            height: 60px;
            line-height: 60px;
            color: var(--text-secondary);
            font-weight: 500;
            font-size: var(--font-body);
            padding: 0;
            width: var(--nav-item-width);
            text-align: center;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
        }

        .el-sub-menu__icon-arrow { display: none !important; }

        .el-menu--horizontal > .el-sub-menu .el-sub-menu__title::after {
            content: '';
            display: inline-block;
            width: 16px;
            height: 16px;
            margin-left: 8px;
            background-repeat: no-repeat;
            background-position: center;
            background-size: 16px 16px;
            background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23767676' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
        }

        .el-sub-menu:hover > .el-sub-menu__title::after,
        .el-sub-menu.is-active > .el-sub-menu__title::after {
            background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230F6CBD' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
        }

        .el-sub-menu.is-opened > .el-sub-menu__title::after {
            background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230F6CBD' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 15 12 9 18 15'/></svg>");
        }

        .el-menu--horizontal > .el-menu-item.is-active,
        .el-menu--horizontal > .el-sub-menu.is-active .el-sub-menu__title {
            color: var(--primary) !important;
            border-bottom: 2px solid var(--primary);
            font-weight: 500;
        }

        .el-menu--horizontal > .el-menu-item:not(.is-disabled):hover,
        .el-menu--horizontal > .el-menu-item:not(.is-disabled):focus,
        .el-menu--horizontal > .el-sub-menu:not(.is-disabled):hover .el-sub-menu__title {
            color: var(--primary);
            background-color: transparent;
        }

        /* 下拉菜单样式覆盖 */
        .el-menu--popup {
            width: var(--nav-item-width) !important;
            min-width: var(--nav-item-width) !important;
            max-width: var(--nav-item-width) !important;
            border-radius: var(--radius-small);
            padding: 4px 0;
            border: 1px solid var(--border-light);
            border-top: 2px solid var(--primary);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            text-align: center !important;
        }

        .el-menu--popup .el-menu-item {
            height: 36px;
            line-height: 36px;
            padding: 0 !important;
            color: var(--text-secondary);
            white-space: nowrap;
            text-align: center;
            width: var(--nav-item-width) !important;
            box-sizing: border-box;
            overflow: hidden;
            text-overflow: ellipsis;
            display: flex !important;
            justify-content: center !important;
            align-items: center !important;
            font-size: var(--font-body);
        }

        .el-menu--popup .el-menu-item:hover {
            background-color: var(--bg-secondary);
            color: var(--primary);
        }

        .user-section {
            display: flex;
            align-items: center;
            gap: var(--spacing-16);
            margin-left: auto;
            z-index: 10;
            width: 200px;
            justify-content: flex-end;
            flex-shrink: 0;
            cursor: pointer;
            padding: 8px 12px;
            border-radius: var(--radius-small);
            transition: background-color var(--transition-fast);
            color: var(--text-secondary);
        }

        .user-section:hover {
            background-color: var(--bg-secondary);
        }

        .user-avatar {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background-color: var(--primary-light);
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--primary);
            font-weight: 500;
        }

        .user-name {
            font-weight: 500;
            font-size: var(--font-body);
            color: var(--text-secondary);
        }

        .user-arrow {
            color: var(--text-tertiary);
            transition: color var(--transition-normal);
        }

        .user-section:hover .user-arrow {
            color: var(--primary);
        }

        /* 用户下拉弹窗 */
        .user-dropdown {
            position: absolute;
            top: 60px;
            right: var(--spacing-24);
            width: 160px;
            background: var(--bg-primary);
            border: 1px solid var(--border-light);
            border-radius: var(--radius-small);
            box-shadow: 0 4px 12px rgba(0,0,0,0.08);
            display: none;
            z-index: 200;
            overflow: hidden;
        }

        .user-dropdown .item {
            padding: 10px 12px;
            color: var(--text-secondary);
            font-size: var(--font-body);
            cursor: pointer;
            white-space: nowrap;
        }

        .user-dropdown .item:hover {
            background-color: var(--bg-secondary);
            color: var(--primary);
        }

        /* 主要内容区域样式 */
        .main-content {
            display: flex;
            flex-direction: column;
            flex: 1;
            height: calc(100vh - 60px); /* 固定高度，减去顶部导航栏高度 */
            background-color: var(--bg-primary);
            width: 100%;
            overflow: hidden; /* 防止内容溢出 */
        }

        /* 面包屑导航样式 */
        .breadcrumb {
            padding: var(--spacing-16) var(--spacing-24);
            display: flex;
            align-items: center;
            border-bottom: 1px solid var(--border-light);
        }

        .breadcrumb-item {
            color: var(--text-tertiary);
            font-size: var(--font-body);
            display: flex;
            align-items: center;
        }

        .breadcrumb-link {
            color: var(--primary);
            text-decoration: none;
            cursor: pointer;
            transition: color var(--transition-normal);
        }

        .breadcrumb-link:hover {
            text-decoration: underline;
        }

        .breadcrumb-separator {
            margin: 0 var(--spacing-8);
            color: var(--text-tertiary);
        }

        /* 药品管理标题栏样式 */
        .combined-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: var(--spacing-24);
            border-bottom: 1px solid var(--border-light);
            background-color: var(--bg-primary);
        }

        .page-title {
            font-size: var(--font-page-title);
            font-weight: 600;
            color: var(--text-primary);
            line-height: var(--line-height-title);
            margin-right: var(--spacing-24);
            white-space: nowrap;
        }

        .header-actions {
            display: flex;
            align-items: center;
            gap: var(--spacing-16);
        }

        /* 搜索框样式 */
        .search-box {
            position: relative;
            width: 200px;
            height: 32px;
        }

        .search-icon {
            position: absolute;
            left: 8px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-tertiary);
            pointer-events: none;
        }

        .search-box input {
            width: 100%;
            height: 100%;
            padding: var(--spacing-8) var(--spacing-8) var(--spacing-8) 32px;
            border: 1px solid var(--border-normal);
            border-radius: var(--radius-small);
            font-size: var(--font-body);
            color: var(--text-primary);
            transition: border-color 0.2s, box-shadow 0.2s;
        }

        .search-box input:focus {
            border-color: var(--primary);
            outline: none;
            box-shadow: 0 0 0 2px rgba(15, 108, 189, 0.2);
        }

        .search-box input::placeholder {
            color: var(--text-tertiary);
        }

        /* 下拉选择器样式 */
        .filter-select {
            height: 32px;
            border: 1px solid var(--border-normal);
            border-radius: var(--radius-small);
            padding: 0 var(--spacing-8);
            font-size: var(--font-body);
            color: var(--text-secondary);
            background-color: var(--bg-primary);
            cursor: pointer;
            transition: border-color 0.2s, box-shadow 0.2s;
        }

        .filter-select:focus {
            border-color: var(--primary);
            outline: none;
            box-shadow: 0 0 0 2px rgba(15, 108, 189, 0.2);
        }

        /* 按钮样式 */
        .btn {
            padding: var(--spacing-8) var(--spacing-16);
            border-radius: var(--radius-small);
            font-size: var(--font-body);
            font-weight: 500;
            cursor: pointer;
            border: none;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            transition: all var(--transition-normal);
            gap: var(--spacing-8);
            height: 36px;
            line-height: 1;
            white-space: nowrap;
        }


        .btn-primary {
            background-color: var(--primary);
            color: white;
        }

        .btn-primary:hover {
            background-color: var(--primary-dark);
        }

        .btn-primary:active {
            background-color: var(--primary-dark);
            transform: translateY(1px);
        }

        .btn-default {
            background-color: var(--bg-secondary);
            color: var(--text-secondary);
            border: 1px solid var(--border-normal);
        }

        .btn-default:hover {
            background-color: var(--bg-primary);
            border-color: var(--border-strong);
            color: var(--text-primary);
        }

        .btn-default:active {
            background-color: var(--bg-secondary);
            transform: translateY(1px);
        }

        /* 主要内容布局 */
        .content-layout {
            display: flex;
            flex: 1;
            overflow: hidden; /* 防止内容溢出 */
            height: 100%; /* 确保占满父容器高度 */
        }

        /* 左侧药品分类树区域 */
        .category-panel {
            width: 280px;
            background-color: var(--bg-primary);
            border-right: 1px solid var(--border-light);
            display: flex;
            flex-direction: column;
            flex-shrink: 0;
            height: 100%; /* 确保面板占满整个高度 */
            overflow: hidden; /* 防止内容溢出 */
        }

        .panel-header {
            padding: var(--spacing-16);
            border-bottom: 1px solid var(--border-light);
        }

        .panel-header .btn {
            padding: var(--spacing-8) var(--spacing-12);
            width: 100%;
        }

        .category-search-box {
            position: relative;
            width: 100%;
            height: 32px;
            margin-bottom: var(--spacing-8);
        }

        .category-search-box input {
            width: 100%;
            height: 100%;
            padding: var(--spacing-8) var(--spacing-8) var(--spacing-8) 32px;
            border: 1px solid var(--border-normal);
            border-radius: var(--radius-small);
            font-size: var(--font-body);
            color: var(--text-primary);
            transition: border-color 0.2s, box-shadow 0.2s;
        }

        .category-search-box input:focus {
            border-color: var(--primary);
            outline: none;
            box-shadow: 0 0 0 2px rgba(15, 108, 189, 0.2);
        }

        .category-search-box input::placeholder {
            color: var(--text-tertiary);
        }

        .category-list {
            flex: 1;
            overflow-y: auto;
            padding: var(--spacing-12);
            max-height: calc(100vh - 180px); /* 限制最大高度，减去顶部导航和搜索框的高度 */
            scrollbar-width: thin; /* Firefox */
            scrollbar-color: var(--border-normal) transparent; /* Firefox */
        }
        
        .category-list::-webkit-scrollbar {
            width: 6px;
        }
        
        .category-list::-webkit-scrollbar-track {
            background: transparent;
        }
        
        .category-list::-webkit-scrollbar-thumb {
            background-color: var(--border-normal);
            border-radius: 3px;
        }
        
        .category-list::-webkit-scrollbar-thumb:hover {
            background-color: var(--border-strong);
        }

        .category-item {
            padding: var(--spacing-8) var(--spacing-12);
            cursor: pointer;
            transition: background-color var(--transition-fast);
            display: flex;
            align-items: center;
            border-radius: var(--radius-small);
            margin: var(--spacing-4) 0;
        }

        .category-item:hover {
            background-color: var(--bg-secondary);
        }

        .category-item.active {
            background-color: var(--primary-light);
            color: var(--primary);
            font-weight: 500;
        }

        .category-tree-node {
            padding-left: var(--spacing-16);
        }

        .category-arrow {
            display: inline-block;
            width: 16px;
            height: 16px;
            margin-right: var(--spacing-4);
            cursor: pointer;
            color: var(--text-tertiary);
            transition: color var(--transition-normal);
            background-repeat: no-repeat;
            background-position: center;
            background-size: 16px 16px;
            background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23767676' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
        }

        .category-arrow:hover {
            color: var(--primary);
            background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230F6CBD' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
        }

        .category-item:hover .category-arrow {
            color: var(--primary);
            background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230F6CBD' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
        }


        .category-spacer {
            display: inline-block;
            width: 16px;
            height: 16px;
            margin-right: var(--spacing-4);
        }

        /* 右侧药品列表区域 */
        .drug-panel {
            flex: 1;
            background-color: var(--bg-primary);
            display: flex;
            flex-direction: column;
            overflow: hidden; /* 改为hidden，防止双重滚动条 */
            height: 100%; /* 确保面板占满整个高度 */
        }

        .drug-list {
            flex: 1;
            padding: var(--spacing-24);
            overflow: auto;
        }

        /* 表格样式 */
        .drug-table {
            width: 100%;
            border-collapse: collapse;
        }

        .drug-table th {
            background-color: var(--bg-secondary);
            padding: var(--spacing-12) var(--spacing-16);
            text-align: left;
            font-weight: 600;
            color: var(--text-secondary);
            border-bottom: 1px solid var(--border-normal);
            height: 40px;
            font-size: var(--font-table-title);
        }

        .drug-table td {
            padding: var(--spacing-12) var(--spacing-16);
            border-bottom: 1px solid var(--border-light);
            color: var(--text-secondary);
            height: 40px;
            vertical-align: middle;
            font-size: var(--font-table);
        }

        .drug-table tr:hover {
            background-color: var(--bg-secondary);
        }

        .drug-table tr:last-child td {
            border-bottom: none;
        }

        /* 操作链接样式 */
        .operations {
            display: inline-flex;
            gap: var(--spacing-8);
        }

        .operation-link {
            color: var(--primary);
            text-decoration: none;
            cursor: pointer;
        }

        .operation-link:hover {
            color: var(--primary-dark);
        }

        .delete-drug {
            color: var(--error);
        }

        .delete-drug:hover {
            color: #B91C1C;
        }

        /* 药品状态标签样式 */
        .drug-status {
            display: inline-block;
            padding: 2px 10px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: 400;
            text-align: center;
            min-width: 36px;
        }

        .drug-status.status-normal {
            background-color: #E6F7F1;
            color: #10B981;
            border: none;
        }

        .drug-status.status-disabled {
            background-color: #F5F5F5;
            color: #767676;
            border: none;
        }

        /* 分页控件样式 */
        .pagination-container {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: var(--spacing-16);
            border-top: 1px solid var(--border-light);
        }

        .pagination-text {
            color: var(--text-tertiary);
            font-size: var(--font-small);
        }

        .pagination-controls {
            display: flex;
            align-items: center;
            gap: var(--spacing-16);
        }

        .page-numbers {
            display: flex;
            gap: var(--spacing-8);
        }

        .page-numbers button {
            min-width: 32px;
            height: 32px;
            border-radius: var(--radius-small);
            border: 1px solid var(--border-normal);
            background: var(--bg-primary);
            cursor: pointer;
            color: var(--text-secondary);
            transition: all var(--transition-normal);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: var(--font-small);
        }

        .page-numbers button:hover {
            border-color: var(--primary);
            color: var(--primary);
        }

        .page-numbers button.active {
            background: var(--primary);
            border-color: var(--primary);
            color: #FFFFFF;
        }

        .pagination-size {
            display: flex;
            align-items: center;
            gap: var(--spacing-8);
            color: var(--text-secondary);
            font-size: var(--font-small);
        }

        .page-size-selector {
            height: 32px;
            border: 1px solid var(--border-normal);
            border-radius: var(--radius-small);
            padding: 0 var(--spacing-8);
            font-size: var(--font-small);
            margin: 0 var(--spacing-4);
        }

        /* 弹窗样式 */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: rgba(0, 0, 0, 0.5);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 1000;
            opacity: 0;
            visibility: hidden;
            transition: opacity var(--transition-normal) ease-out;
            backdrop-filter: blur(2px);
        }

        .modal-overlay[style*="display: flex"] {
            opacity: 1;
            visibility: visible;
        }

        .modal {
            background-color: var(--bg-primary);
            border-radius: var(--radius-small);
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
            width: 100%;
            height: 100%;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            transform: scale(0.98);
            transition: transform var(--transition-normal) ease-out;
        }

        .modal-overlay[style*="display: flex"] .modal {
            transform: scale(1);
        }

        .modal-header {
            padding: var(--spacing-16) var(--spacing-24);
            border-bottom: 1px solid var(--border-light);
            display: flex;
            justify-content: space-between;
            align-items: center;
            height: 48px;
            background-color: var(--bg-primary);
        }

        .modal-title {
            font-size: var(--font-card-title);
            font-weight: 600;
            color: var(--text-primary);
            line-height: var(--line-height-title);
        }

        .modal-close {
            cursor: pointer;
            color: var(--text-tertiary);
            font-size: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
            border-radius: var(--radius-small);
            transition: background-color var(--transition-fast), color var(--transition-fast);
        }

        .modal-close:hover {
            color: var(--text-primary);
            background-color: var(--bg-secondary);
        }

        .modal-body {
            flex: 1;
            padding: var(--spacing-24);
            overflow-y: auto;
        }

        .modal-footer {
            padding: var(--spacing-16) var(--spacing-24);
            border-top: 1px solid var(--border-light);
            display: flex;
            justify-content: flex-end;
            gap: var(--spacing-16);
            background-color: var(--bg-primary);
        }

        /* 表单区域样式 */
        .form-section {
            margin-bottom: var(--spacing-24);
            border: 1px solid var(--border-light);
            border-radius: var(--radius-small);
            overflow: hidden;
        }

        .section-header {
            padding: var(--spacing-12) var(--spacing-16);
            background-color: var(--bg-secondary);
            border-bottom: 1px solid var(--border-light);
        }

        .section-title {
            font-size: var(--font-card-title);
            font-weight: 600;
            color: var(--text-primary);
            margin: 0;
        }

        .section-content {
            padding: var(--spacing-16);
            background-color: var(--bg-primary);
        }

        /* 多列布局表单 */
        .form-row {
            display: flex;
            flex-wrap: wrap;
            margin: 0 -8px;
            gap: var(--spacing-16) 0;
        }

        .form-row.two-columns .form-item {
            width: calc(50% - 16px);
            margin: 0 8px;
        }

        .form-row.five-columns .form-item {
            width: calc(20% - 16px);
            margin: 0 8px;
        }

        .form-row.six-columns .form-item {
            width: calc(16.666% - 16px);
            margin: 0 8px;
        }

        .form-item {
            position: relative;
        }

        .form-label {
            display: block;
            margin-bottom: var(--spacing-8);
            font-weight: 500;
            color: var(--text-secondary);
            font-size: var(--font-body);
        }

        .required-mark {
            color: var(--error);
            margin-left: 4px;
            display: inline;
        }

        .form-control {
            width: 100%;
            height: 32px;
            padding: 0 var(--spacing-12);
            border: 1px solid var(--border-normal);
            border-radius: var(--radius-small);
            font-size: var(--font-body);
            color: var(--text-primary);
            transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
            line-height: 30px;
        }

        .form-control:focus {
            border-color: var(--primary);
            outline: none;
            box-shadow: 0 0 0 2px rgba(15, 108, 189, 0.2);
        }

        .form-control:disabled {
            background-color: var(--bg-disabled);
            color: var(--text-disabled);
        }

        /* 复选框样式 */
        .checkbox-item {
            display: flex;
            flex-direction: column;
        }

        .checkbox-wrapper {
            display: flex;
            align-items: center;
            gap: var(--spacing-8);
            height: 32px;
        }

        .checkbox-wrapper input[type="checkbox"] {
            width: 16px;
            height: 16px;
            accent-color: var(--primary);
        }

        /* 单选按钮样式 */
        .radio-item {
            display: flex;
            flex-direction: column;
        }

        .radio-group {
            display: flex;
            gap: var(--spacing-16);
            height: 32px;
            align-items: center;
        }

        .radio-wrapper {
            display: flex;
            align-items: center;
            gap: var(--spacing-8);
        }

        .radio-wrapper input[type="radio"] {
            width: 16px;
            height: 16px;
            accent-color: var(--primary);
        }
        
        /* 下拉框样式修复 */
        select.form-control {
            appearance: none;
            background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23767676' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
            background-repeat: no-repeat;
            background-position: right 8px center;
            padding-right: 32px;
            text-overflow: ellipsis;
        }

        /* 文本区域样式 */
        .textarea-control {
            width: 100%;
            min-height: 120px;
            padding: var(--spacing-8) var(--spacing-12);
            border: 1px solid var(--border-normal);
            border-radius: var(--radius-small);
            font-size: var(--font-body);
            color: var(--text-primary);
            font-family: inherit;
            resize: vertical;
            transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
        }

        .textarea-control:focus {
            border-color: var(--primary);
            outline: none;
            box-shadow: 0 0 0 2px rgba(15, 108, 189, 0.2);
        }

        /* 图片库样式 */
        .image-gallery {
            display: flex;
            flex-wrap: wrap;
            gap: var(--spacing-16);
            margin-bottom: var(--spacing-16);
        }

        .image-item {
            width: 120px;
            height: 120px;
            border: 1px solid var(--border-normal);
            border-radius: var(--radius-small);
            overflow: hidden;
            position: relative;
            background-color: var(--bg-secondary);
        }

        .image-placeholder {
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-tertiary);
            font-size: var(--font-small);
        }

        .image-actions {
            position: absolute;
            top: 0;
            right: 0;
            padding: var(--spacing-4);
        }

        .image-action-btn {
            width: 24px;
            height: 24px;
            border-radius: 50%;
            background-color: rgba(0, 0, 0, 0.6);
            color: white;
            border: none;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            font-size: 16px;
            transition: background-color var(--transition-fast);
        }

        .image-action-btn:hover {
            background-color: rgba(0, 0, 0, 0.8);
        }

        .image-upload-item {
            width: 120px;
            height: 120px;
            border: 1px dashed var(--border-normal);
            border-radius: var(--radius-small);
            overflow: hidden;
            position: relative;
            cursor: pointer;
            transition: border-color var(--transition-normal), background-color var(--transition-normal);
        }

        .image-upload-item:hover {
            border-color: var(--primary);
            background-color: rgba(15, 108, 189, 0.05);
        }

        .upload-placeholder {
            width: 100%;
            height: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: var(--text-tertiary);
            font-size: var(--font-small);
            transition: color var(--transition-normal);
        }

        .image-upload-item:hover .upload-placeholder {
            color: var(--primary);
        }

        .upload-icon {
            font-size: 24px;
            margin-bottom: var(--spacing-4);
        }

        .image-upload-hint {
            color: var(--text-tertiary);
            font-size: var(--font-small);
        }

        /* 响应式样式 */
        @media (max-width: 768px) {
            .header {
                flex-wrap: wrap;
                padding: var(--spacing-12) var(--spacing-16);
                height: auto;
            }

            .header-spacer {
                width: 100%;
                justify-content: center;
                margin-bottom: 8px;
            }

            .user-section {
                width: 100%;
                justify-content: center;
                order: 3;
                margin-top: 8px;
            }

            #app-nav {
                position: relative;
                left: 0;
                transform: none;
                width: 100%;
                order: 3;
                margin-top: var(--spacing-8);
            }

            .el-menu--horizontal {
                flex-wrap: wrap;
                width: 100%;
                overflow-x: auto;
                white-space: nowrap;
                -webkit-overflow-scrolling: touch;
                padding-bottom: var(--spacing-4);
                justify-content: center;
            }

            .el-menu--horizontal > .el-menu-item,
            .el-menu--horizontal > .el-sub-menu .el-sub-menu__title {
                height: 48px;
                line-height: 48px;
            }

            .el-menu--popup {
                position: fixed;
                top: auto !important;
                left: 0 !important;
                right: 0 !important;
                width: 100%;
                max-height: 60vh;
                overflow-y: auto;
                border-radius: 8px 8px 0 0;
            }

            .breadcrumb {
                padding: var(--spacing-12) var(--spacing-16);
            }

            .combined-header {
                padding: var(--spacing-16);
                flex-direction: column;
                gap: var(--spacing-16);
                align-items: stretch;
            }

            .header-actions {
                flex-wrap: wrap;
                gap: var(--spacing-8);
            }

            .search-box {
                flex: 1;
                min-width: 200px;
            }

            .content-layout {
                flex-direction: column;
            }

            .category-panel {
                width: 100%;
                border-right: none;
                border-bottom: 1px solid var(--border-light);
            }

            .drug-table {
                min-width: 600px;
            }

            .drug-list {
                padding: var(--spacing-16);
            }

            .pagination-container {
                flex-direction: column;
                gap: var(--spacing-16);
                align-items: flex-start;
            }

            .pagination-controls {
                flex-direction: column;
                align-items: flex-start;
                gap: var(--spacing-12);
                width: 100%;
            }

            .page-numbers {
                flex-wrap: wrap;
            }

            .modal {
                width: 95%;
                max-width: none;
                height: 95%;
                margin: var(--spacing-16);
            }
        }
    </style>
</head>
<body>
    <div id="app" class="container">
        <!-- 顶部导航栏 - 使用Element Plus组件 -->
        <header class="header">
            <div class="header-spacer"></div>
            <div id="app-nav">
                <el-menu
                    :default-active="activeIndex"
                    class="el-menu-demo"
                    mode="horizontal"
                    @select="handleSelect"
                    :ellipsis="false"
                    :popper-offset="0"
                    popper-class="custom-dropdown">
                    <el-menu-item index="1">开始问诊</el-menu-item>
                    <el-sub-menu index="2" popper-class="custom-dropdown">
                        <template #title>病历管理</template>
                        <el-menu-item index="2-1">病历查询</el-menu-item>
                        <el-menu-item index="2-2">病历模板</el-menu-item>
                        <el-menu-item index="2-3">个人药品</el-menu-item>
                    </el-sub-menu>
                    <el-menu-item index="3">患者管理</el-menu-item>
                    <el-sub-menu index="4" popper-class="custom-dropdown">
                        <template #title>数据统计</template>
                        <el-menu-item index="4-1">诊断统计</el-menu-item>
                        <el-menu-item index="4-2">宏观统计</el-menu-item>
                    </el-sub-menu>
                    <el-menu-item index="5">医学知识</el-menu-item>
                    <el-sub-menu index="6" popper-class="custom-dropdown">
                        <template #title>基础数据</template>
                        <el-menu-item index="6-1">药品管理</el-menu-item>
                    </el-sub-menu>
                    <el-sub-menu index="7" popper-class="custom-dropdown">
                        <template #title>消息通知</template>
                        <el-menu-item index="7-1">通知查看</el-menu-item>
                        <el-menu-item index="7-2">通知发布</el-menu-item>
                    </el-sub-menu>
                    <el-sub-menu index="8" popper-class="custom-dropdown">
                        <template #title>用户管理</template>
                        <el-menu-item index="8-1">用户管理</el-menu-item>
                        <el-menu-item index="8-2">角色管理</el-menu-item>
                    </el-sub-menu>
                </el-menu>
            </div>
            <div class="user-section" id="userSection">
                <span class="user-name">张医生</span>
                <svg class="user-arrow" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                    <polyline points="6 9 12 15 18 9"></polyline>
                </svg>
            </div>
            <div class="user-dropdown" id="userDropdown">
                <div class="item">个人中心</div>
                <div class="item">退出登录</div>
            </div>
        </header>

        <!-- 主要内容区域 -->
        <div class="main-content">

            <!-- 药品管理标题栏 -->
            <section class="combined-header">
                <h1 class="page-title">药品管理</h1>
                <div class="header-actions">
                    <div class="search-box">
                        <svg class="search-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                            <circle cx="11" cy="11" r="8"></circle>
                            <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
                        </svg>
                        <input type="text" id="drugSearchInput" placeholder="搜索药品...">
                    </div>
                    <select class="filter-select" id="statusFilter">
                        <option value="all">状态: 全部</option>
                        <option value="normal">启用</option>
                        <option value="disabled">停用</option>
                    </select>
                    <select class="filter-select" id="basicDrugFilter">
                        <option value="all">基本药物: 全部</option>
                        <option value="yes">是</option>
                        <option value="no">否</option>
                    </select>
                    <button class="btn btn-primary" id="queryBtn">查询</button>
                    <button class="btn btn-default" id="resetBtn">重置</button>
                    <button class="btn btn-primary" id="addDrugBtn">新增药品</button>
                    <button class="btn btn-default" id="importBtn">批量导入</button>
                </div>
            </section>

            <!-- 内容布局 -->
            <div class="content-layout">
                <!-- 左侧药品分类树区域 -->
                <div class="category-panel">
                    <div class="panel-header">
                        <div class="category-search-box">
                            <svg class="search-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                                <circle cx="11" cy="11" r="8"></circle>
                                <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
                            </svg>
                            <input type="text" id="categorySearchInput" placeholder="搜索分类...">
                        </div>
                    </div>
                    <div id="categoryList" class="category-list">
                        <!-- 分类树将在JavaScript中动态生成 -->
                    </div>
                </div>

                <!-- 右侧药品列表区域 -->
                <div class="drug-panel">
                    <div class="drug-list">
                        <table class="drug-table">
                            <thead>
                                <tr>
                                    <th>药品名称</th>
                                    <th>药品编码</th>
                                    <th>规格</th>
                                    <th>剂型</th>
                                    <th>单位</th>
                                    <th>基本药物</th>
                                    <th>状态</th>
                                    <th>常用用法</th>
                                    <th>常用用量</th>
                                    <th>常用频次</th>
                                    <th>适应症</th>
                                    <th>禁忌症</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody id="drugTableBody">
                                <!-- 药品数据将在JavaScript中动态生成 -->
                            </tbody>
                        </table>
                    </div>

                    <!-- 分页控件 -->
                    <div class="pagination-container">
                        <div class="pagination-text">共 <span id="totalDrugs">0</span> 条记录</div>
                        <div class="pagination-controls">
                            <div id="pageNumbers" class="page-numbers">
                                <!-- 页码按钮将在JavaScript中动态生成 -->
                            </div>
                            <div class="pagination-size">
                                每页显示
                                <select id="pageSizeSelector" class="page-size-selector">
                                    <option value="10" selected>10</option>
                                    <option value="20">20</option>
                                    <option value="50">50</option>
                                </select>
                                条
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 药品编辑/新增弹窗（全屏模式） -->
        <div id="drugModal" class="modal-overlay" style="display: none;">
            <div class="modal">
                <div class="modal-header">
                    <h3 class="modal-title">药品编辑/新增</h3>
                    <span class="modal-close" id="closeDrugModal">×</span>
                </div>
                <div class="modal-body">
                    <!-- 药品基本信息 -->
                    <div class="form-section">
                        <div class="section-header">
                            <h3 class="section-title">药品基本信息</h3>
                        </div>
                        <div class="section-content">
                            <div class="form-row five-columns">
                                <div class="form-item">
                                    <label class="form-label" for="drugName">药品名称 <span class="required-mark">*</span></label>
                                    <input type="text" id="drugName" class="form-control" placeholder="请输入药品名称" required>
                                </div>
                                <div class="form-item">
                                    <label class="form-label" for="drugCode">药品编码 <span class="required-mark">*</span></label>
                                    <input type="text" id="drugCode" class="form-control" placeholder="请输入药品编码" required>
                                </div>
                                <div class="form-item">
                                    <label class="form-label" for="drugCategory">药品分类 <span class="required-mark">*</span></label>
                                    <select id="drugCategory" class="form-control" required>
                                        <option value="">请选择药品分类</option>
                                        <!-- 分类选项将在JavaScript中动态生成 -->
                                    </select>
                                </div>
                                <div class="form-item radio-item">
                                    <label class="form-label">基本药物</label>
                                    <div class="radio-group">
                                        <div class="radio-wrapper">
                                            <input type="radio" id="isBasicDrugYes" name="isBasicDrug" value="1">
                                            <label for="isBasicDrugYes">是</label>
                                        </div>
                                        <div class="radio-wrapper">
                                            <input type="radio" id="isBasicDrugNo" name="isBasicDrug" value="0" checked>
                                            <label for="isBasicDrugNo">否</label>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-item radio-item">
                                    <label class="form-label">药品状态</label>
                                    <div class="radio-group">
                                        <div class="radio-wrapper">
                                            <input type="radio" id="statusNormal" name="drugStatus" value="normal" checked>
                                            <label for="statusNormal">启用</label>
                                        </div>
                                        <div class="radio-wrapper">
                                            <input type="radio" id="statusDisabled" name="drugStatus" value="disabled">
                                            <label for="statusDisabled">停用</label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- 药品规格与用法用量 -->
                    <div class="form-section">
                        <div class="section-header">
                            <h3 class="section-title">药品规格与用法用量</h3>
                        </div>
                        <div class="section-content">
                            <div class="form-row six-columns">
                                <div class="form-item">
                                    <label class="form-label" for="drugSpec">规格 <span class="required-mark">*</span></label>
                                    <input type="text" id="drugSpec" class="form-control" placeholder="请输入规格" required>
                                </div>
                                <div class="form-item">
                                    <label class="form-label" for="drugForm">剂型 <span class="required-mark">*</span></label>
                                    <select id="drugForm" class="form-control" required>
                                        <option value="">请选择</option>
                                        <option value="tablet">片剂</option>
                                        <option value="capsule">胶囊</option>
                                        <option value="injection">注射剂</option>
                                        <option value="liquid">液体剂</option>
                                        <option value="granule">颗粒剂</option>
                                        <option value="powder">散剂</option>
                                    </select>
                                </div>
                                <div class="form-item">
                                    <label class="form-label" for="drugUnit">单位 <span class="required-mark">*</span></label>
                                    <select id="drugUnit" class="form-control" required>
                                        <option value="">请选择</option>
                                        <option value="tablet">片</option>
                                        <option value="mg">mg</option>
                                        <option value="ml">ml</option>
                                        <option value="g">g</option>
                                        <option value="bag">袋</option>
                                        <option value="bottle">瓶</option>
                                    </select>
                                </div>
                                <div class="form-item">
                                    <label class="form-label" for="commonUsage">常用用法 <span class="required-mark">*</span></label>
                                    <select id="commonUsage" class="form-control" required>
                                        <option value="">请选择</option>
                                        <option value="oral">口服</option>
                                        <option value="injection">注射</option>
                                        <option value="topical">外用</option>
                                        <option value="inhalation">吸入</option>
                                        <option value="infusion">静滴</option>
                                    </select>
                                </div>
                                <div class="form-item">
                                    <label class="form-label" for="commonFrequency">常用频次 <span class="required-mark">*</span></label>
                                    <select id="commonFrequency" class="form-control" required>
                                        <option value="">请选择</option>
                                        <option value="1次/日">1次/日</option>
                                        <option value="2次/日">2次/日</option>
                                        <option value="3次/日">3次/日</option>
                                        <option value="4次/日">4次/日</option>
                                        <option value="必要时">必要时</option>
                                    </select>
                                </div>
                                <div class="form-item">
                                    <label class="form-label" for="commonDosage">常用用量 <span class="required-mark">*</span></label>
                                    <input type="text" id="commonDosage" class="form-control" placeholder="如：1片/次" required>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- 适应症与禁忌症 -->
                    <div class="form-section">
                        <div class="section-header">
                            <h3 class="section-title">适应症与禁忌症</h3>
                        </div>
                        <div class="section-content">
                            <div class="form-row two-columns">
                                <div class="form-item">
                                    <label class="form-label" for="indications">适应症 <span class="required-mark">*</span></label>
                                    <textarea id="indications" class="textarea-control" placeholder="请输入适应症" required></textarea>
                                </div>
                                <div class="form-item">
                                    <label class="form-label" for="contraindications">禁忌症 <span class="required-mark">*</span></label>
                                    <textarea id="contraindications" class="textarea-control" placeholder="请输入禁忌症" required></textarea>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- 药品图片 -->
                    <div class="form-section">
                        <div class="section-header">
                            <h3 class="section-title">药品图片</h3>
                        </div>
                        <div class="section-content">
                            <div class="image-gallery">
                                <div class="image-upload-item">
                                    <div class="upload-placeholder">
                                        <span class="upload-icon">+</span>
                                        <span class="upload-text">上传图片</span>
                                    </div>
                                    <input type="file" id="uploadImage" accept="image/*" style="display: none;">
                                </div>
                            </div>
                            <div class="image-upload-hint">
                                支持多张药品图片上传，点击图片可查看大图，最多可上传8张图片
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-default" id="cancelDrugBtn">取消</button>
                    <button class="btn btn-primary" id="saveDrugBtn">保存</button>
                </div>
            </div>
        </div>
    </div>

    <!-- JavaScript 交互逻辑 -->
    <script>
        // 创建Vue应用
        document.addEventListener('DOMContentLoaded', function() {
            const { createApp, ref } = Vue;

            // 创建导航菜单Vue应用
            const navApp = createApp({
                setup() {
                    const activeIndex = ref('6-1'); // 默认选中"药品管理"

                    const handleSelect = (key, keyPath) => {
                        console.log(key, keyPath);
                        // 这里可以添加导航逻辑，如页面跳转等
                    };

                    return {
                        activeIndex,
                        handleSelect
                    };
                }
            });

            // 使用Element Plus
            navApp.use(ElementPlus, {
                locale: ElementPlusLocaleZhCn
            });

            // 挂载导航Vue应用
            navApp.mount('#app-nav');

            // 用户下拉菜单交互
            const userSection = document.getElementById('userSection');
            const userDropdown = document.getElementById('userDropdown');

            if (userSection && userDropdown) {
                userSection.addEventListener('click', function(e) {
                    e.stopPropagation();
                    const isOpen = userDropdown.style.display === 'block';
                    userDropdown.style.display = isOpen ? 'none' : 'block';
                });

                document.addEventListener('click', function() {
                    userDropdown.style.display = 'none';
                });
            }

            // 药品分类树数据（预设分类）
            const categoryTree = [
                {
                    id: 1,
                    name: '抗感染药物',
                    children: [
                        { id: 11, name: '抗生素类', children: [
                            { id: 111, name: '青霉素类' },
                            { id: 112, name: '头孢菌素类' },
                            { id: 113, name: '大环内酯类' }
                        ]},
                        { id: 12, name: '抗病毒药', children: [
                            { id: 121, name: '抗流感病毒药' },
                            { id: 122, name: '抗疱疹病毒药' },
                            { id: 123, name: '抗肝炎病毒药' }
                        ]},
                        { id: 13, name: '抗真菌药', children: [
                            { id: 131, name: '咪唑类' },
                            { id: 132, name: '三唑类' },
                            { id: 133, name: '多烯类' }
                        ]}
                    ]
                },
                {
                    id: 2,
                    name: '解热镇痛药',
                    children: [
                        { id: 21, name: '非甾体抗炎药' },
                        { id: 22, name: '阿片类镇痛药' }
                    ]
                },
                {
                    id: 3,
                    name: '心脑血管药物',
                    children: [
                        { id: 31, name: '降压药' },
                        { id: 32, name: '降脂药' },
                        { id: 33, name: '抗心律失常药' }
                    ]
                },
                {
                    id: 4,
                    name: '消化系统药物',
                    children: [
                        { id: 41, name: '抗溃疡药' },
                        { id: 42, name: '胃肠动力药' },
                        { id: 43, name: '止泻药' }
                    ]
                },
                {
                    id: 5,
                    name: '呼吸系统药物',
                    children: [
                        { id: 51, name: '平喘药' },
                        { id: 52, name: '镇咳药' },
                        { id: 53, name: '祛痰药' }
                    ]
                },
                {
                    id: 6,
                    name: '内分泌系统药物',
                    children: [
                        { id: 61, name: '降糖药' },
                        { id: 62, name: '甲状腺药物' }
                    ]
                },
                {
                    id: 7,
                    name: '神经系统药物',
                    children: [
                        { id: 71, name: '抗精神病药' },
                        { id: 72, name: '抗抑郁药' },
                        { id: 73, name: '抗焦虑药' }
                    ]
                },
                {
                    id: 8,
                    name: '血液系统药物',
                    children: [
                        { id: 81, name: '抗凝血药' },
                        { id: 82, name: '抗血小板药' }
                    ]
                },
                {
                    id: 9,
                    name: '维生素及营养药',
                    children: [
                        { id: 91, name: '水溶性维生素' },
                        { id: 92, name: '脂溶性维生素' },
                        { id: 93, name: '微量元素' }
                    ]
                },
                {
                    id: 10,
                    name: '中药',
                    children: [
                        { id: 101, name: '中成药' },
                        { id: 102, name: '中药饮片' }
                    ]
                }
            ];

            // 药品数据
            let drugs = [
                {
                    id: 1,
                    name: '阿莫西林',
                    code: 'AM001',
                    spec: '0.25g/片',
                    form: '片剂',
                    unit: '片',
                    isBasic: true,
                    status: 'normal',
                    usage: '口服',
                    dosage: '0.25g/次',
                    frequency: '3次/日',
                    indications: '呼吸道感染',
                    contraindications: '过敏史',
                    categoryId: 111
                },
                {
                    id: 2,
                    name: '头孢克洛',
                    code: 'TB002',
                    spec: '0.25g/片',
                    form: '片剂',
                    unit: '片',
                    isBasic: true,
                    status: 'normal',
                    usage: '口服',
                    dosage: '0.25g/次',
                    frequency: '2次/日',
                    indications: '细菌感染',
                    contraindications: '肾功能不全',
                    categoryId: 112
                },
                {
                    id: 3,
                    name: '布洛芬',
                    code: 'BL003',
                    spec: '0.2g/片',
                    form: '片剂',
                    unit: '片',
                    isBasic: true,
                    status: 'normal',
                    usage: '口服',
                    dosage: '0.2g/次',
                    frequency: '3次/日',
                    indications: '发热镇痛',
                    contraindications: '胃溃疡',
                    categoryId: 2
                },
                {
                    id: 4,
                    name: '阿司匹林',
                    code: 'AS004',
                    spec: '25mg/片',
                    form: '片剂',
                    unit: '片',
                    isBasic: true,
                    status: 'disabled',
                    usage: '口服',
                    dosage: '25mg/次',
                    frequency: '1次/日',
                    indications: '抗血栓',
                    contraindications: '出血倾向',
                    categoryId: 3
                },
                {
                    id: 5,
                    name: '板蓝根',
                    code: 'BL005',
                    spec: '10g/袋',
                    form: '颗粒剂',
                    unit: '袋',
                    isBasic: true,
                    status: 'normal',
                    usage: '冲服',
                    dosage: '10g/次',
                    frequency: '3次/日',
                    indications: '感冒发热',
                    contraindications: '孕妇慎用',
                    categoryId: 102
                }
            ];

            // 当前选中的分类ID
            let currentCategoryId = null;

            // 分页信息
            let currentPage = 1;
            let pageSize = 10;
            let totalPages = 0;

            // 初始化分类树
            function initCategoryTree() {
                const categoryList = document.getElementById('categoryList');
                categoryList.innerHTML = '';

                function renderCategory(category, level = 0) {
                    const item = document.createElement('div');
                    item.className = `category-item${currentCategoryId === category.id ? ' active' : ''}`;
                    item.dataset.id = category.id;
                    item.dataset.level = level;

                    const indent = '&nbsp;'.repeat(level * 4);
                    const hasChildren = category.children && category.children.length > 0;
                    
                    // 只有有子项的分类才显示箭头
                    const arrow = hasChildren ?
                        '<span class="category-arrow" data-expanded="true"></span>' : '<span class="category-spacer"></span>';

                    item.innerHTML = `
                        ${indent}${arrow}
                        <span>${category.name}</span>
                    `;

                    // 点击事件 - 区分箭头点击和分类项点击
                    item.addEventListener('click', function(e) {
                        // 检查点击是否在箭头上
                        const isArrowClick = e.target.classList.contains('category-arrow') || 
                                            (e.target.parentElement && e.target.parentElement.querySelector('.category-arrow') === e.target);
                        
                        if (isArrowClick && hasChildren) {
                            // 点击箭头，展开/收起子分类
                            toggleCategory(category.id);
                            e.stopPropagation(); // 阻止事件冒泡
                        } else {
                            // 点击分类项，选择分类
                            document.querySelectorAll('.category-item').forEach(i => i.classList.remove('active'));
                            this.classList.add('active');
                            currentCategoryId = category.id;
                            filterDrugs();
                            renderDrugTable();
                        }
                    });

                    categoryList.appendChild(item);

                    // 递归渲染子分类（默认展开）
                    if (category.children && category.children.length > 0) {
                        category.children.forEach(child => {
                            const childItem = renderCategory(child, level + 1);
                            childItem.dataset.parentId = category.id; // 记录父级ID，便于展开/收起
                        });
                    }

                    return item;
                }

                // 切换分类展开/收起状态
                function toggleCategory(categoryId) {
                    const items = document.querySelectorAll('.category-item');
                    const parentItem = Array.from(items).find(item => parseInt(item.dataset.id) === categoryId);
                    
                    if (!parentItem) return;
                    
                    const arrow = parentItem.querySelector('.category-arrow');
                    if (!arrow) return;
                    
                    const isCurrentlyExpanded = arrow.getAttribute('data-expanded') === 'true';
                    const newExpandedState = !isCurrentlyExpanded;
                    
                    // 更新箭头方向
                    updateArrowDirection(parentItem, newExpandedState);
                    
                    // 查找直接子分类
                    const childItems = Array.from(items).filter(item => 
                        item.dataset.parentId && parseInt(item.dataset.parentId) === categoryId
                    );
                    
                    // 切换直接子分类的显示状态
                    childItems.forEach(item => {
                        item.style.display = newExpandedState ? 'flex' : 'none';
                        
                        // 如果收起父级，则递归收起所有子级
                        if (!newExpandedState) {
                            const childArrow = item.querySelector('.category-arrow');
                            if (childArrow && childArrow.getAttribute('data-expanded') === 'true') {
                                // 递归收起子分类
                                toggleCategory(parseInt(item.dataset.id));
                            }
                        }
                    });
                }
                
                // 查找所有子分类项
                function findChildItems(parentId) {
                    const result = [];
                    let isDirectChild = false;
                    let level = 0;
                    
                    // 递归查找分类树中的子项
                    function findChildrenInTree(categories, targetId, currentLevel) {
                        for (const category of categories) {
                            if (category.id === targetId) {
                                if (category.children) {
                                    return category.children.map(child => ({
                                        id: child.id,
                                        level: currentLevel + 1,
                                        hasChildren: child.children && child.children.length > 0
                                    }));
                                }
                                return [];
                            }
                            
                            if (category.children) {
                                const found = findChildrenInTree(category.children, targetId, currentLevel + 1);
                                if (found.length > 0) return found;
                            }
                        }
                        return [];
                    }
                    
                    // 获取直接子项的信息
                    const directChildren = findChildrenInTree(categoryTree, parentId, 0);
                    
                    // 在DOM中查找对应的元素
                    if (directChildren.length > 0) {
                        const items = document.querySelectorAll('.category-item');
                        directChildren.forEach(childInfo => {
                            const childItem = Array.from(items).find(item => parseInt(item.dataset.id) === childInfo.id);
                            if (childItem) {
                                result.push(childItem);
                            }
                        });
                    }
                    
                    return result;
                }

                // 更新箭头方向
                function updateArrowDirection(item, isExpanded) {
                    const arrow = item.querySelector('.category-arrow');
                    if (arrow) {
                        if (isExpanded) {
                            arrow.setAttribute('data-expanded', 'true');
                            arrow.style.backgroundImage = 'url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\' width=\'16\' height=\'16\' viewBox=\'0 0 24 24\' fill=\'none\' stroke=\'%230F6CBD\' stroke-width=\'2\' stroke-linecap=\'round\' stroke-linejoin=\'round\'><polyline points=\'6 15 12 9 18 15\'/></svg>")';
                        } else {
                            arrow.setAttribute('data-expanded', 'false');
                            arrow.style.backgroundImage = 'url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\' width=\'16\' height=\'16\' viewBox=\'0 0 24 24\' fill=\'none\' stroke=\'%230F6CBD\' stroke-width=\'2\' stroke-linecap=\'round\' stroke-linejoin=\'round\'><polyline points=\'6 9 12 15 18 9\'/></svg>")';
                        }
                    }
                }
                
                // 检查分类是否有子项
                function hasChildCategories(categoryId) {
                    function findCategory(categories, id) {
                        for (const category of categories) {
                            if (category.id === id) {
                                return category.children && category.children.length > 0;
                            }
                            if (category.children) {
                                const found = findCategory(category.children, id);
                                if (found !== null) return found;
                            }
                        }
                        return null;
                    }
                    return findCategory(categoryTree, categoryId) || false;
                }

                categoryTree.forEach(category => renderCategory(category));
            }

            // 分类搜索功能
            const categorySearchInput = document.getElementById('categorySearchInput');
            categorySearchInput.addEventListener('input', function() {
                const searchTerm = this.value.toLowerCase();
                filterCategories(searchTerm);
            });

            function filterCategories(searchTerm) {
                const items = document.querySelectorAll('.category-item');
                let visibleCount = 0;

                items.forEach(item => {
                    const text = item.textContent.trim();
                    const isMatch = searchTerm === '' || text.toLowerCase().includes(searchTerm);

                    if (isMatch) {
                        item.style.display = 'flex';
                        visibleCount++;
                        if (visibleCount === 1) {
                            // 高亮第一个匹配项
                            item.scrollIntoView({ behavior: 'smooth', block: 'center' });
                            item.style.backgroundColor = '#fff3cd';
                            setTimeout(() => {
                                item.style.backgroundColor = '';
                            }, 2000);
                        }
                    } else {
                        item.style.display = 'none';
                    }
                });

                // 如果没有匹配项，显示提示信息
                if (visibleCount === 0 && searchTerm !== '') {
                    showCategorySearchTip();
                }
            }

            function showCategorySearchTip() {
                // 在分类列表末尾显示提示信息
                const categoryList = document.getElementById('categoryList');
                let tipElement = document.getElementById('category-search-tip');

                if (!tipElement) {
                    tipElement = document.createElement('div');
                    tipElement.id = 'category-search-tip';
                    tipElement.className = 'category-search-tip';
                    tipElement.style.cssText = `
                        padding: 12px;
                        text-align: center;
                        color: #999;
                        font-size: 12px;
                        background: #f5f5f5;
                        border-radius: 4px;
                        margin: 8px 0;
                    `;
                    categoryList.appendChild(tipElement);
                }

                tipElement.textContent = '未找到匹配的分类，请尝试其他关键词';
                tipElement.style.display = 'block';

                // 清空搜索框时隐藏提示
                setTimeout(() => {
                    if (categorySearchInput.value === '') {
                        tipElement.style.display = 'none';
                    }
                }, 100);
            }

            // 筛选药品
            function filterDrugs() {
                const searchTerm = document.getElementById('drugSearchInput').value.toLowerCase();
                const statusFilter = document.getElementById('statusFilter').value;
                const basicDrugFilter = document.getElementById('basicDrugFilter').value;

                let filteredDrugs = drugs.filter(drug => {
                    // 文本搜索
                    if (searchTerm && !drug.name.toLowerCase().includes(searchTerm) &&
                        !drug.code.toLowerCase().includes(searchTerm)) {
                        return false;
                    }

                    // 状态筛选
                    if (statusFilter !== 'all' && drug.status !== statusFilter) {
                        return false;
                    }

                    // 基本药物筛选
                    if (basicDrugFilter !== 'all') {
                        const isBasic = basicDrugFilter === 'yes';
                        if (drug.isBasic !== isBasic) {
                            return false;
                        }
                    }

                    // 分类筛选
                    if (currentCategoryId && drug.categoryId !== currentCategoryId) {
                        // 检查是否是当前分类的子分类
                        if (!isChildCategory(currentCategoryId, drug.categoryId)) {
                            return false;
                        }
                    }

                    return true;
                });

                return filteredDrugs;
            }

            // 检查是否是子分类
            function isChildCategory(parentId, childId) {
                function findCategory(categories, targetId) {
                    for (const category of categories) {
                        if (category.id === targetId) return true;
                        if (category.children) {
                            if (findCategory(category.children, targetId)) return true;
                        }
                    }
                    return false;
                }
                return findCategory(categoryTree, childId);
            }

            // 渲染药品表格
            function renderDrugTable() {
                const filteredDrugs = filterDrugs();
                const drugTableBody = document.getElementById('drugTableBody');
                const totalDrugsSpan = document.getElementById('totalDrugs');

                // 更新总数
                totalDrugsSpan.textContent = filteredDrugs.length;

                // 计算分页
                totalPages = Math.ceil(filteredDrugs.length / pageSize);
                const startIndex = (currentPage - 1) * pageSize;
                const endIndex = startIndex + pageSize;
                const pageDrugs = filteredDrugs.slice(startIndex, endIndex);

                // 清空表格
                drugTableBody.innerHTML = '';

                // 渲染药品行
                pageDrugs.forEach(drug => {
                    const row = document.createElement('tr');
                    row.innerHTML = `
                        <td>${drug.name}</td>
                        <td>${drug.code}</td>
                        <td>${drug.spec}</td>
                        <td>${drug.form}</td>
                        <td>${drug.unit}</td>
                        <td>${drug.isBasic ? '是' : '否'}</td>
                        <td><span class="drug-status ${drug.status === 'normal' ? 'status-normal' : 'status-disabled'}">${drug.status === 'normal' ? '启用' : '停用'}</span></td>
                        <td>${drug.usage || '-'}</td>
                        <td>${drug.dosage || '-'}</td>
                        <td>${drug.frequency || '-'}</td>
                        <td>${drug.indications || '-'}</td>
                        <td>${drug.contraindications || '-'}</td>
                        <td>
                            <div class="operations">
                                <a class="operation-link edit-drug" data-id="${drug.id}">编辑</a>
                                <a class="operation-link delete-drug" data-id="${drug.id}">删除</a>
                            </div>
                        </td>
                    `;
                    drugTableBody.appendChild(row);
                });

                // 渲染分页控件
                renderPagination();
            }

            // 渲染分页控件
            function renderPagination() {
                const pageNumbersDiv = document.getElementById('pageNumbers');
                pageNumbersDiv.innerHTML = '';

                // 页码按钮
                const startPage = Math.max(1, currentPage - 2);
                const endPage = Math.min(totalPages, currentPage + 2);

                for (let i = startPage; i <= endPage; i++) {
                    const pageBtn = document.createElement('button');
                    pageBtn.textContent = i;
                    pageBtn.className = i === currentPage ? 'active' : '';
                    pageBtn.addEventListener('click', () => {
                        currentPage = i;
                        renderDrugTable();
                    });
                    pageNumbersDiv.appendChild(pageBtn);
                }
            }

            // 查询按钮事件
            document.getElementById('queryBtn').addEventListener('click', function() {
                currentPage = 1;
                renderDrugTable();
            });
            
            // 重置按钮事件
            document.getElementById('resetBtn').addEventListener('click', function() {
                document.getElementById('drugSearchInput').value = '';
                document.getElementById('statusFilter').value = 'all';
                document.getElementById('basicDrugFilter').value = 'all';
                currentPage = 1;
                renderDrugTable();
            });

            // 新增药品按钮事件
            document.getElementById('addDrugBtn').addEventListener('click', function() {
                openDrugModal('add');
            });

            // 批量导入按钮事件
            document.getElementById('importBtn').addEventListener('click', function() {
                alert('批量导入功能：请选择Excel文件进行药品批量导入');
            });

            // 药品编辑事件
            document.addEventListener('click', function(e) {
                if (e.target.classList.contains('edit-drug')) {
                    const drugId = parseInt(e.target.dataset.id);
                    const drug = drugs.find(d => d.id === drugId);
                    if (drug) {
                        openDrugModal('edit', drug);
                    }
                }
            });

            // 药品删除事件
            document.addEventListener('click', function(e) {
                if (e.target.classList.contains('delete-drug')) {
                    const drugId = parseInt(e.target.dataset.id);
                    if (confirm('确定要删除这个药品吗？')) {
                        drugs = drugs.filter(d => d.id !== drugId);
                        renderDrugTable();
                        alert('药品已删除');
                    }
                }
            });

            // 弹窗相关变量
            let currentModalMode = 'add'; // 'add' or 'edit'
            let currentDrugId = null;

            // 打开药品弹窗
            function openDrugModal(mode, drug = null) {
                currentModalMode = mode;
                
                // 重置图片区域
                resetImageUploadArea();

                if (mode === 'edit' && drug) {
                    // 设置弹窗标题
                    document.querySelector('.modal-title').textContent = '药品编辑';
                    
                    currentDrugId = drug.id;
                    // 填充表单数据
                    document.getElementById('drugName').value = drug.name;
                    document.getElementById('drugCode').value = drug.code;
                    document.getElementById('drugSpec').value = drug.spec;
                    document.getElementById('drugForm').value = drug.form;
                    document.getElementById('drugUnit').value = drug.unit;
                    document.querySelector(`input[name="isBasicDrug"][value="${drug.isBasic ? '1' : '0'}"]`).checked = true;
                    document.querySelector(`input[name="drugStatus"][value="${drug.status}"]`).checked = true;
                    document.getElementById('commonUsage').value = drug.usage || '';
                    document.getElementById('commonDosage').value = drug.dosage || '';
                    document.getElementById('commonFrequency').value = drug.frequency || '';
                    document.getElementById('indications').value = drug.indications || '';
                    document.getElementById('contraindications').value = drug.contraindications || '';

                    // 设置分类选择器
                    setTimeout(() => {
                        document.getElementById('drugCategory').value = drug.categoryId;
                    }, 100);
                    
                    // 如果有图片，模拟加载图片（实际应用中应从服务器获取）
                    if (drug.id % 2 === 0) { // 仅作为演示，偶数ID的药品有示例图片
                        setTimeout(() => {
                            const placeholder = document.querySelector('#imagePreview1 .image-placeholder');
                            const deleteBtn = document.querySelector('#imagePreview1 .image-delete-btn');
                            
                            placeholder.innerHTML = '';
                            const img = document.createElement('img');
                            img.src = 'https://via.placeholder.com/120x120?text=药品图片';
                            img.style.width = '100%';
                            img.style.height = '100%';
                            img.style.objectFit = 'cover';
                            placeholder.appendChild(img);
                            
                            deleteBtn.style.display = 'flex';
                            currentImageCount = 1;
                        }, 200);
                    }
                } else {
                    // 设置弹窗标题
                    document.querySelector('.modal-title').textContent = '新增药品';
                    
                    // 清空表单
                    document.getElementById('drugName').value = '';
                    document.getElementById('drugCode').value = '';
                    document.getElementById('drugSpec').value = '';
                    document.getElementById('drugForm').value = '';
                    document.getElementById('drugUnit').value = '';
                    document.querySelector('input[name="isBasicDrug"][value="0"]').checked = true;
                    document.querySelector('input[name="drugStatus"][value="normal"]').checked = true;
                    document.getElementById('commonUsage').value = '';
                    document.getElementById('commonDosage').value = '';
                    document.getElementById('commonFrequency').value = '';
                    document.getElementById('indications').value = '';
                    document.getElementById('contraindications').value = '';
                    document.getElementById('drugCategory').value = '';
                    currentDrugId = null;
                }

                document.getElementById('drugModal').style.display = 'flex';
            }
            
            // 重置图片上传区域
            function resetImageUploadArea() {
                // 重置图片计数
                currentImageCount = 0;
                
                // 显示上传按钮
                document.querySelector('.image-upload-item').style.display = 'block';
                
                // 清除所有预览图片
                document.querySelectorAll('.image-item').forEach(item => {
                    item.remove(); // 移除所有图片预览位置
                });
            }

            // 关闭药品弹窗
            function closeDrugModal() {
                document.getElementById('drugModal').style.display = 'none';
            }

            // 保存药品
            function saveDrug() {
                const drugData = {
                    name: document.getElementById('drugName').value.trim(),
                    code: document.getElementById('drugCode').value.trim(),
                    spec: document.getElementById('drugSpec').value.trim(),
                    form: document.getElementById('drugForm').value,
                    unit: document.getElementById('drugUnit').value,
                    isBasic: document.querySelector('input[name="isBasicDrug"]:checked').value === '1',
                    status: document.querySelector('input[name="drugStatus"]:checked').value,
                    usage: document.getElementById('commonUsage').value,
                    dosage: document.getElementById('commonDosage').value,
                    frequency: document.getElementById('commonFrequency').value,
                    indications: document.getElementById('indications').value.trim(),
                    contraindications: document.getElementById('contraindications').value.trim(),
                    categoryId: parseInt(document.getElementById('drugCategory').value)
                };

                // 验证必填项
                if (!drugData.name || !drugData.code || !drugData.spec || !drugData.form || !drugData.unit || 
                    !drugData.categoryId || !drugData.usage || !drugData.dosage || !drugData.frequency || 
                    !drugData.indications || !drugData.contraindications) {
                    alert('请填写所有必填项（带*号的字段）');
                    return;
                }

                // 检查编码唯一性
                const existingDrug = drugs.find(d => d.code === drugData.code && d.id !== currentDrugId);
                if (existingDrug) {
                    alert('药品编码已存在，请使用其他编码');
                    return;
                }

                if (currentModalMode === 'add') {
                    // 新增药品
                    drugData.id = Math.max(...drugs.map(d => d.id)) + 1;
                    drugs.push(drugData);
                    alert('药品添加成功');
                } else {
                    // 编辑药品
                    const index = drugs.findIndex(d => d.id === currentDrugId);
                    if (index !== -1) {
                        drugs[index] = { ...drugs[index], ...drugData };
                        alert('药品修改成功');
                    }
                }

                closeDrugModal();
                renderDrugTable();
            }

            // 初始化分类选择器选项
            function initCategorySelect() {
                const categorySelect = document.getElementById('drugCategory');

                function addCategoryOptions(categories, level = 0) {
                    categories.forEach(category => {
                        const option = document.createElement('option');
                        option.value = category.id;
                        option.textContent = '  '.repeat(level) + category.name;
                        categorySelect.appendChild(option);

                        if (category.children) {
                            addCategoryOptions(category.children, level + 1);
                        }
                    });
                }

                addCategoryOptions(categoryTree);
            }

            // 绑定弹窗事件
            document.getElementById('closeDrugModal').addEventListener('click', closeDrugModal);
            document.getElementById('cancelDrugBtn').addEventListener('click', closeDrugModal);
            document.getElementById('saveDrugBtn').addEventListener('click', saveDrug);

            // 点击遮罩层关闭弹窗
            document.getElementById('drugModal').addEventListener('click', function(e) {
                if (e.target === this) {
                    closeDrugModal();
                }
            });

            // 图片上传和预览功能
            const imageUploadItem = document.querySelector('.image-upload-item');
            const uploadImageInput = document.getElementById('uploadImage');
            let currentImageCount = 0;
            const MAX_IMAGES = 8;
            
            // 点击上传区域触发文件选择
            imageUploadItem.addEventListener('click', function() {
                if (currentImageCount < MAX_IMAGES) {
                    uploadImageInput.click();
                } else {
                    alert('最多只能上传8张图片');
                }
            });
            
            // 文件选择后处理
            uploadImageInput.addEventListener('change', function(e) {
                if (e.target.files && e.target.files[0]) {
                    const file = e.target.files[0];
                    
                    // 检查是否是图片
                    if (!file.type.match('image.*')) {
                        alert('请选择图片文件');
                        return;
                    }
                    
                    // 检查图片数量
                    if (currentImageCount >= MAX_IMAGES) {
                        alert('最多只能上传8张图片');
                        return;
                    }
                    
                    // 创建新的预览位置
                    const imageGallery = document.querySelector('.image-gallery');
                    const newImageItem = document.createElement('div');
                    const newPreviewId = currentImageCount + 1;
                    newImageItem.className = 'image-item';
                    newImageItem.id = `imagePreview${newPreviewId}`;
                    
                    newImageItem.innerHTML = `
                        <div class="image-placeholder"></div>
                        <div class="image-actions">
                            <button class="image-action-btn image-delete-btn" title="删除">×</button>
                        </div>
                    `;
                    
                    // 插入到上传按钮之前
                    imageGallery.insertBefore(newImageItem, imageUploadItem);
                    
                    // 创建图片预览
                    const placeholder = newImageItem.querySelector('.image-placeholder');
                    const itemDeleteBtn = newImageItem.querySelector('.image-delete-btn');
                    
                    const reader = new FileReader();
                    reader.onload = function(e) {
                        const img = document.createElement('img');
                        img.src = e.target.result;
                        img.style.width = '100%';
                        img.style.height = '100%';
                        img.style.objectFit = 'cover';
                        placeholder.appendChild(img);
                        
                        // 增加图片计数
                        currentImageCount++;
                        
                        // 如果达到最大数量，隐藏上传按钮
                        if (currentImageCount >= MAX_IMAGES) {
                            imageUploadItem.style.display = 'none';
                        }
                    };
                    reader.readAsDataURL(file);
                    
                    // 添加删除事件
                    itemDeleteBtn.addEventListener('click', function(e) {
                        e.stopPropagation();
                        newImageItem.remove();
                        currentImageCount--;
                        imageUploadItem.style.display = 'block';
                    });
                    
                    // 重置文件输入，以便可以再次选择相同的文件
                    this.value = '';
                }
            });
            
            // 设置点击图片查看大图的委托事件
            document.querySelector('.image-gallery').addEventListener('click', function(e) {
                // 查找最近的image-item父元素
                const imageItem = e.target.closest('.image-item');
                if (!imageItem) return;
                
                // 确保点击的不是删除按钮
                if (e.target.closest('.image-delete-btn')) return;
                
                const img = imageItem.querySelector('img');
                if (img) {
                    // 创建大图预览
                    const overlay = document.createElement('div');
                    overlay.style.position = 'fixed';
                    overlay.style.top = '0';
                    overlay.style.left = '0';
                    overlay.style.right = '0';
                    overlay.style.bottom = '0';
                    overlay.style.backgroundColor = 'rgba(0,0,0,0.8)';
                    overlay.style.zIndex = '2000';
                    overlay.style.display = 'flex';
                    overlay.style.alignItems = 'center';
                    overlay.style.justifyContent = 'center';
                    overlay.style.cursor = 'pointer';
                    
                    const largeImg = document.createElement('img');
                    largeImg.src = img.src;
                    largeImg.style.maxWidth = '90%';
                    largeImg.style.maxHeight = '90%';
                    largeImg.style.objectFit = 'contain';
                    
                    overlay.appendChild(largeImg);
                    document.body.appendChild(overlay);
                    
                    // 点击关闭大图
                    overlay.addEventListener('click', function() {
                        document.body.removeChild(overlay);
                    });
                }
            });

            // 每页显示数量选择
            document.getElementById('pageSizeSelector').addEventListener('change', function() {
                pageSize = parseInt(this.value);
                currentPage = 1;
                renderDrugTable();
            });

            // 初始化页面
            initCategoryTree();
            initCategorySelect();
            renderDrugTable();
        });
    </script>
</body>
</html>
